class Solution {
    public String minNumber(int[] nums) {
        int len = nums.length;
        String[] arr = new String[len];
        for(int i = 0 ;i < len;i++) {
            arr[i] = String.valueOf(nums[i]);
        }
        qsort(arr,0,len-1);
        StringBuilder s = new StringBuilder();
        for(String x : arr) {
            s.append(x);
        }
        return s.toString();
    }
    private void qsort(String[] arr,int left,int right) {
        if(left<right) {
            int mid = findMid(arr,left,right);
            qsort(arr,left,mid-1);
            qsort(arr,mid+1,right);
        }

    }
    private int findMid(String[] arr,int left,int right) {
        //最左边作为基准值
        String cur = arr[left];
        while(left<right) {
            while(left<right && (cur+arr[right]).compareTo(arr[right]+cur)<=0) {
                right--;
            }
            arr[left] = arr[right];
            while(left<right && (cur+arr[left]).compareTo(arr[left]+cur)>=0) {
                left++;
            }
            arr[right] = arr[left];
        }
        arr[left] = cur;
        return left;
    }

}